package org.jetnuke.modules.download;

import java.util.Date;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.velocity.VelocityContext;
import org.jetnuke.common.ActionForward;
import org.jetnuke.common.IAction;
import org.jetnuke.common.IAdminInfo;
import org.jetnuke.common.IModuleInfo;
import org.jetnuke.common.IUserInfo;
import org.jetnuke.dao.DataAccessDriver;

public class Download implements IAction {

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.jetnuke.common.IAction#exec(javax.servlet.http.HttpServletRequest,
	 *      javax.servlet.http.HttpServletResponse,
	 *      org.apache.velocity.VelocityContext, org.jetnuke.common.IModuleInfo,
	 *      java.lang.String, null, null)
	 */
	public ActionForward exec(HttpServletRequest request,
			HttpServletResponse response, VelocityContext vc, IModuleInfo info,
			String op, IUserInfo ui, IAdminInfo ai) throws Exception {

		vc.put("cats", 
				DataAccessDriver.getInst().newDownloadCategoriesDAO().selectByParent(0));
				//downloads_categoriesPeer.doSelect(new Criteria().add(
				//downloads_categoriesPeer.PARENTID, 0)
				//.addAscendingOrderByColumn(downloads_categoriesPeer.TITLE)));
		vc.put("num_down", new Integer(
				DataAccessDriver.getInst().newDownloadDownloadDAO().countAll()));
				//downloads_downloadsPeer
				//.count(new Criteria())));
		vc.put("num_cats", new Integer(DataAccessDriver.getInst().newDownloadCategoriesDAO().countAll()));
		vc.put("dt", new Date());
		return new ActionForward(op, info);
	}

}
